package org.example.myjavaweb_de.servlet;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.example.myjavaweb_de.User.Student;
import org.example.myjavaweb_de.padao.paqdao;

import java.io.IOException;
import java.security.URIParameter;
import java.util.List;

@WebServlet(urlPatterns = "/mm")
public class mmm extends GenericServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("myservelt");
    }
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;

        //请求设置中文
        request.setCharacterEncoding("utf-8");
        //响应设置中文编码
        response.setContentType("text/html;charset=UTF-8");
        paqdao xdao=new paqdao();
        List<Student> sa=xdao.queryall();
        //Student sa=xdao.queryone(3);
        if(sa!=null){
            response.getWriter().println(sa);
        }
        /**
         response.getWriter().println("<table border=\"1\" cellspacing=\"0\" cellpadding=\"6\";>");
        for(Student s:sa){
            response.getWriter().println("<tr>");
            response.getWriter().println("<td>"+s.getStu()+"</td>");
            response.getWriter().println("<td>"+s.getStus()+"</td>");
            response.getWriter().println("</tr>");
        }

        response.getWriter().println("</table>");
         **/
        //response.addIntHeader("refresh",3);
       // response.setHeader("refresh","3;url=index.html");
    }
}
